

<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<title>Grade Bay</title>
		<link rel="stylesheet" href="gui.css" type="text/css" />
		<!--[if IE 7]>
			<link rel="stylesheet" href="css/ie7.css" type="text/css" />
		<![endif]-->
	</head>
	<body>
		<div class="page">
			<div class="header">
				<a href="index.php" id="logo"><img src="images/gradeBaylogo.png" width="330" height="79" alt=""/></a>
				<ul>
					<li class="selected"><a href="">ADD TEACHER</a></li>
					
				
				</ul>
			</div>
			<div class="body">
                         
                         
 <?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
    include 'PHPClasses/DBAccess.php';
    include 'PHPClasses/TeacherDBAccess.php';
    include 'PHPClasses/Teacher.php';
   
    error_reporting(E_ERROR | E_PARSE);
    
    if (isset($_POST['submitted']))
    { 
        $DBAccess=new TeacherDBAccess();
        $Teacher=new Teacher();
        $Teacher->setTeacherName($_POST["teachName"]);
        $levels=$_POST["level"];
        $Teacher->setLevels($levels);
                                            
        $errormsg=$DBAccess->validate($Teacher,FALSE);
                                        
        if ($errormsg){ 
            
             header("Location: http://localhost/paragox-infinity-introse/addTeacher.php?error=".$errormsg."");
        }
        else
        {
            $DBAccess->addToDB($Teacher);
         
            
            
             echo "<script> 
               if(confirm('Successfully Added! Add some more teachers?')){
                    window.location='http://localhost/paragox-infinity-introse/addTeacher.php';
               }
               
               else{
                window.location='http://localhost/paragox-infinity-introse/viewTeachers.php';
                  }   
               
               </script>"; 
        }
        
        $DBAccess->DBDisconnect(); 
     }  
     
?>
				
				</div>
			
		</div>
	</body>
</html>  